import random

# 打印1-9
for i in range(1,10+1,2):  # 0-9
    print(i, end="\t")

# 打印1-9
for i in range(1,10+1,2):  # 0-9
    print(i, end="\t")

# 打印100以内 能被3整除的数字
for i in range(1,100+1):
    if i % 3 == 0:
        print(i, end="\t")
# 猜数字
# 产生随机数
num = random.randint(1,100)
while True:
    guess = int(input("请输入一个数字"))
    if guess > num:
        print("太大了")
    elif guess < num:
        print("太小了")
    else:
        print("猜对了")
        break  # 结束循环

#100以内能被7整除的数字
for i in range(1,100+1):
   # if i % 7 ==0 or str(i).find('7') != -1:
   # if i % 7 ==0 or str(i).count('7') > 0:
   if i % 7 ==0 or '7' in str(i) != -1:
        print(i, end="\t")

# 打印菱形
for i in range(1,11+1,2):
     print(("*" * i).center(11)) # center 字符串居中
for i in range(9, 0, -2):
         print(("*" * i).center(11))

# 打印菱形2 多层循环嵌套

# 打印100以内的质数

# 打印水仙花数
for number in range(100, 1000):
    # 分解出百位、十位和个位
    a = number // 100
    b = (number // 10) % 10
    c = number % 10

    # 计算各位数字的立方和
    i = a ** 3 + b ** 3 + c ** 3

    # 判断是否为水仙花数
    if i == number:
        print(number)

# 打印斐波那契数列


# 打印九九乘法表
for i in range(1,10):
   for j in range (1,i+1):
       print("%d*%d=%d"%(j,i,j*i),end="\t")
   print()

# 打印完数

for i in range(1,101):
    sum = 0
    for j in range(1,i):
        if i % j == 0:
            sum += j
    if sum == i:
        print(f"{i}是完数")

# for i in range(2,100):
#     for j in range(2,i):
#         if i % j == 0:
#             break
#     else:
#             print(i)


# for i in range(1,101):
#     sum = 0
#     for j in range(1,i):
#         if i % j ==0:
#             sum+=j
#     if sum==i:
#             print(i)

# a,b=0,1
# fib=[]
# for i in range(39):
#     fib.append(b)
#     a,b=b,a+b
# print(fib)

for i in range(1,9,2):
     print(("*"*i).center(9))
for i in range(9,0,-2):
     print(("*"*i).center(9))


for i in range(1, 100):

    if i % 3 == 0 and i % 7 == 0:
        print(i, end=' ')




